<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商家审核</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>

    <!--引入自定义文件-->
    <script src="../js/pages/public.js"></script>
</head>

<body class="hold-transition skin-red sidebar-mini">
<!-- .box-body -->
<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">商家审核</h3>
    </div>

    <div class="box-body">

        <!-- 数据表格 -->
        <div class="table-box">

            <!--工具栏-->

            <div class="box-tools pull-right">
                <div class="has-feedback">
                    <form id="FormIds">
                        公司名称：<input name="name">
                        店铺名称：<input name="nickName">
                        <input type="button" class="btn btn-default" onclick="getNameAndNickName()" value="查询">
                        <input type="button" class="btn btn-default" onclick="location.reload()" value="刷新">
                    </form>

                </div>
            </div>
            <!--工具栏/-->

            <!--数据列表-->
            <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                <thead>
                <tr>
                    <th class="" style="padding-right:0px">
                        <input id="selall" type="checkbox" class="icheckbox_square-blue">
                    </th>
                    <th class="sorting_asc">商家ID</th>
                    <th class="sorting">公司名称</th>
                    <th class="sorting">店铺名称</th>
                    <th class="sorting">联系人姓名</th>
                    <th class="sorting">公司电话</th>

                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="tbodySellerId">
                <!--			                          <tr>-->
                <!--			                              <td><input  type="checkbox"></td>			                              -->
                <!--				                          <td>1</td>-->
                <!--									      <td>梦琪琪商贸有限公司</td>-->
                <!--									      <td>梦琪琪</td>-->
                <!--									      <td>李梦琪</td>-->
                <!--									      <td>13402312232</td>-->
                <!--		                                 -->
                <!--		                                  <td class="text-center">                                           -->
                <!--		                                 	  <button type="button" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#sellerModal" >详情</button>                                           -->
                <!--		                                  </td>-->
                <!--			                          </tr>-->
                </tbody>
            </table>
            <!--数据列表/-->


        </div>
        <!-- 数据表格 /-->
        <form id="indexForm">
            <a href="javascript:toPage(3)">首页</a>
            <a href="javascript:toPage(1)">上一页</a>
            <a href="javascript:toPage(2)">下一页</a>
            <a href="javascript:toPage(4)">尾页</a>
            第<input type="text" name="pageNum" id="pageNum" size="1px" readonly="readonly">页
            共<input type="text" name="pages" id="pages" size="1px" disabled="disabled">页
            共<input type="text" name="total" id="total" size="1px" disabled="disabled">条
        </form>


    </div>
</div>
<!-- /.box-body -->


<!-- 商家详情 -->
<div class="modal fade" id="sellerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">商家详情</h3>
            </div>
            <div class="modal-body">

                <ul class="nav nav-tabs">
                    <li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
                    <li><a href="#linkman" data-toggle="tab">联系人</a></li>
                    <li><a href="#certificate" data-toggle="tab">证件</a></li>
                    <li><a href="#ceo" data-toggle="tab">法定代表人</a></li>
                    <li><a href="#bank" data-toggle="tab">开户行</a></li>
                </ul>

                <!-- 选项卡开始 -->
                <div id="DigDIV">
                </div>
                <!-- 选项卡结束 -->


            </div>
            <div class="modal-footer">
                <input type="hidden" id="sellerId">
                <button class="btn btn-success" data-dismiss="modal" aria-hidden="true" onclick="SetAudit(1)">审核通过</button>
                <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true"  onclick="SetAudit(2)">审核未通过</button>
                <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true"  onclick="SetAudit(3)">关闭商家</button>
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
            </div>
        </div>
    </div>
</div>


</body>
<script th:inline="javascript">
    $(function () {
        getSellerList();
    })

    function getSellerList() {
        $.ajax({
            url: domain + "/seller/getSllerList",
            headers: {"Autherizetion": window.localStorage.getItem("token")},
            // contentType:"application/json;charset=utf-8",
            dataType: "json",
            type: "post",
            data: $("#indexForm").serialize(),
            success: function (result) {
                if (result.code == 11) {
                    console.log(result)
                    var data = result.data.rows;
                    var html = '';
                    $(data).each(function (i, e) {
                        html += '<tr>\n' +
                            '\t\t\t                              <td><input value="' + e.sellerId + '" type="checkbox"></td>\t\t\t                              \n' +
                            '\t\t\t\t                          <td>' + e.sellerId + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.name + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.nickName + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.linkmanName + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.telephone + '</td>\n' +
                            '\t\t                                  \n' +
                            '\t\t                                  <td class="text-center">                                           \n' +
                            '\t\t                                 \t  <button type="button" class="btn bg-olive btn-xs" data-toggle="modal" onclick="getId(\'' + e.sellerId + '\')" data-target="#sellerModal" >详情</button>                                           \n' +
                            '\t\t                                  </td>\n' +
                            '\t\t\t                          </tr>';
                    })
                    $("#tbodySellerId").html(html)
                    $("#pageNum").val(result.data.pageNum)
                    $("#pages").val(result.data.pages)
                    $("#total").val(result.data.total)
                } else if (result.code == 12) {
                    top.window.location.href = "../login.html";//token失效   重新登录获取token  重新走网关的全局过滤器进行校验
                }
            }
        })
    }

    /*分页*/
    function toPage(id) {
        var pageNum = parseInt($("#pageNum").val());
        var pages = parseInt($("#pages").val());
        if (id == 1) {
            if (pageNum <= 1) {
                alert("已是首页");
                return;
            }
            $("#pageNum").val(pageNum - 1);
        } else if (id == 2) {
            if (pageNum >= pages) {
                alert("已是尾页");
                return;
            }
            $("#pageNum").val(pageNum + 1);
        } else if (id == 3) {
            $("#pageNum").val(1);
        } else if (id == 4) {
            $("#pageNum").val(pages);
        }
        getSellerList();
    }

    function getNameAndNickName() {
        var from = $("#FormIds").serializeObject();
        $.ajax({
            url: domain + "/seller/getNameAndLinkeName",
            headers: {"Autherizetion": window.localStorage.getItem("token")},
            contentType: "application/json;charset=utf-8",
            type: "post",
            dataType: "json",
            data: JSON.stringify(from),
            success: function (result) {
                if (result.code == 11) {
                    console.log(result)

                    var data = result.data;
                    var html = '';
                    $(data).each(function (i, e) {
                        html += '<tr>\n' +
                            '\t\t\t                              <td><input value="' + e.sellerId + '" type="checkbox"></td>\t\t\t                              \n' +
                            '\t\t\t\t                          <td>' + e.sellerId + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.name + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.nickName + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.linkmanName + '</td>\n' +
                            '\t\t\t\t\t\t\t\t\t      <td>' + e.telephone + '</td>\n' +
                            '\t\t                                  \n' +
                            '\t\t                                  <td class="text-center">                                           \n' +
                            '\t\t                                 \t  <button type="button" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#sellerModal" >详情</button>                                           \n' +
                            '\t\t                                  </td>\n' +
                            '\t\t\t                          </tr>';
                    })
                    $("#tbodySellerId").html(html)
                } else if (result.code == 12) {
                    top.window.location.href = "../login.html";
                }
            }, error: function () {
                alert("模糊查询异常")
            }
        })
    }

    function getId(id) {
        $("#sellerId").val(id)
        $.ajax({
            url: domain + "/seller/getId",
            headers: {"Autherizetion": window.localStorage.getItem("token")},
            // contentType:"application/json;charset=utf-8",
            dataType: "json",
            type: "get",
            data: {sellerId: id},
            success: function (result) {
                var e = result.data;
                var html1 = '';
                // $(data).each(function (i, e) {
                html1 += '<div id="myTabContent" class="tab-content">\n' +
                    '                        <div class="tab-pane active in" id="home">\n' +
                    '                            <br>\n' +
                    '                            <table class="table table-bordered table-striped" width="800px">\n' +
                    '                                <tr>\n' +
                    '                                    <td>公司名称</td>\n' +
                    '                                    <td>' + e.name + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>公司手机</td>\n' +
                    '                                    <td>' + e.mobile + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>公司电话</td>\n' +
                    '                                    <td>' + e.telephone + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>公司详细地址</td>\n' +
                    '                                    <td>' + e.addressDetail + '</td>\n' +
                    '                                </tr>\n' +
                    '                            </table>\n' +
                    '                        </div>\n' +
                    '                        <div class="tab-pane fade" id="linkman">\n' +
                    '                            <br>\n' +
                    '                            <table class="table table-bordered table-striped">\n' +
                    '                                <tr>\n' +
                    '                                    <td>联系人姓名</td>\n' +
                    '                                    <td>' + e.linkmanName + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>联系人QQ</td>\n' +
                    '                                    <td>' + e.linkmanQq + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>联系人手机</td>\n' +
                    '                                    <td>' + e.linkmanMobile + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>联系人E-Mail</td>\n' +
                    '                                    <td>' + e.linkmanEmail + '</td>\n' +
                    '                                </tr>\n' +
                    '                            </table>\n' +
                    '                        </div>\n' +
                    '                        <div class="tab-pane fade" id="certificate">\n' +
                    '                            <br>\n' +
                    '                            <table class="table table-bordered table-striped">\n' +
                    '                                <tr>\n' +
                    '                                    <td>营业执照号</td>\n' +
                    '                                    <td>' + e.licenseNumber + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>税务登记证号</td>\n' +
                    '                                    <td>' + e.taxNumber + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>组织机构代码证号</td>\n' +
                    '                                    <td>' + e.orgNumber + '</td>\n' +
                    '                                </tr>\n' +
                    '                            </table>\n' +
                    '                        </div>\n' +
                    '                        <div class="tab-pane fade" id="ceo">\n' +
                    '                            <br>\n' +
                    '                            <table class="table table-bordered table-striped">\n' +
                    '                                <tr>\n' +
                    '                                    <td>法定代表人</td>\n' +
                    '                                    <td>' + e.legalPerson + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>法定代表人身份证号</td>\n' +
                    '                                    <td>' + e.legalPersonCardId + '</td>\n' +
                    '                                </tr>\n' +
                    '                            </table>\n' +
                    '                        </div>\n' +
                    '                        <div class="tab-pane fade" id="bank">\n' +
                    '                            <br>\n' +
                    '                            <table class="table table-bordered table-striped">\n' +
                    '                                <tr>\n' +
                    '                                    <td>开户行名称</td>\n' +
                    '                                    <td>' + e.bankUser + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>开户行支行</td>\n' +
                    '                                    <td>' + e.bankName + '</td>\n' +
                    '                                </tr>\n' +
                    '                                <tr>\n' +
                    '                                    <td>银行账号</td>\n' +
                    '                                    <td>' + e.bankName + '</td>\n' +
                    '                                </tr>\n' +
                    '                            </table>\n' +
                    '                        </div>\n' +
                    '                    </div>';
                // });
                $("#DigDIV").html(html1)
            }, error: function () {
                alert("异常")
            }
        })
    }

    //审核通过按钮
    function SetAudit(status) {
        var sellerId = $("#sellerId").val();
        $.ajax({
            url: domain + "/seller/SetAudit",
            headers: {"Autherizetion": window.localStorage.getItem("token")},
            // contentType: "application/json;charset=utf-8",
            type: "put",
            dataType: "json",
            data: {sellerId:sellerId,status: status},//JSON.stringify(from)
            success: function (result) {
                if (result.code == 11) {
                    alert("修改状态成功")
                    location.reload();
                } else if (result.code == 12) {
                    top.window.location.href = "../login.html";//token失效   重新登录  获取token 通过网关 全局过滤器   top：显示完整页面
                }
            }
        })
    }

</script>
</html>